//1、编写 router/index.js文件
//引入 router
import { createMemoryHistory, createRouter } from 'vue-router'

//引入组件
import Login from '@/components/Login.vue'
import Register from '@/components/Register.vue'
import Main from '@/components/Main.vue'
import List from '@/components/main/list.vue'
import Upload from '@/components/main/upload.vue'

//2、配置路由表信息
const routes = [
    {
        path: '/login',          //访问的路劲
        name: 'login',       //名称
        component: Login  //组件
    },
    {
        path: '/register',          //访问的路劲
        name: 'register',       //名称
        component: Register  //组件
    },
    {
        path: '/main',
        name: 'main',
        component: Main,
        //子路由的访问地址前面没有/，完整访问地址：/父路径/子路径
        children: [
            {
                path: 'list',
                name: 'list',
                component: List
            },
            //使用路径传参数，后面使用`:变量名
            {
                path: 'upload/:id/:name',
                name: 'upload',
                component: Upload
            }
        ]
    }
]

//创建路由器
const router = createRouter({
    history: createMemoryHistory(),
    routes,
})
export { router }